import os, errno, random,time
orig_small = "/tmp/small.orig"
orig_big = "/tmp/big.orig"
big_file = "/tmp/fs/big.csv"
actual_big_file = "/tmp/sqlfslog/big.csv"
small_file = "/tmp/fs/small.csv"
actual_small_file = "/tmp/sqlfslog/small.csv"
def read_file(actual_file, test_file):
    f1 = open(actual_file)
    f2 = open(test_file)
    start = time.time()
    while(True):
        line = f1.readline()
        if not line:
            break
    actual_time = time.time() - start
    start = time.time()
    while(True):
        line = f2.readline()
        if not line:
            break
    test_time = time.time() - start
    print "%s [actual] read time: %f" % (actual_file, actual_time)
    print "%s [test] read time: %f" % (test_file, test_time)

def write_file(orig_file, actual_file, test_file):
    f = open(orig_file)
    f1 = open(actual_file, 'w')
    f2 = open(test_file, 'w')
    start = time.time()
    while(True):
        line = f.readline()
        if not line:
            break
        print >>f1, line,
    f1.close()
    actual_time = time.time() - start
    f.seek(0)
    while(True):
        line = f.readline()
        if not line:
            break
        print >>f2, line,
    f2.close()
    test_time = time.time() - start    
    print "%s [actual] write time: %f" % (actual_file, actual_time)
    print "%s [test] write time:%f" % (test_file, test_time) 

if __name__== '__main__':
    read_file(actual_small_file, small_file)
    read_file(actual_big_file, big_file)
    #write_file(orig_small, actual_small_file, small_file)
    #write_file(orig_big, actual_big_file, big_file)    